﻿namespace Softserve.Pottery.UnitTesting
{
    using System;
    using System.Collections.Generic;
    using System.Xml;
    using NUnit.Framework;
    using Softserve.Pottery.Infrastructure;
    using Softserve.Pottery.Infrastructure.Serialization;
    using Softserve.Pottery.Manufacturing.Domains;
    using Softserve.Pottery.Ordering.Domains;
    using Softserve.Pottery.Store.Domains;
    using Softserve.Pottery.Warehouse.Domains;
    using Softserve.Pottery.Infrastructure.Interfaces;

    [TestFixture(typeof(Approvement))]
    [TestFixture(typeof(Batch))]
    [TestFixture(typeof(Plan))]
    [TestFixture(typeof(Team))]
    [TestFixture(typeof(Notification))]
    [TestFixture(typeof(Order))]
    [TestFixture(typeof(Payment))]
    [TestFixture(typeof(Product))]
    [TestFixture(typeof(User))]
    [TestFixture(typeof(Address))]
    [TestFixture(typeof(PotteryWarehouse))]
    //[TestFixture(typeof(Catalog))]
    public class DomainValidation<TDomain> where TDomain : IValidatable, IDomain, new()
    {
        [Test]
        public void ValidateDomain()
        {
            string fileName = pr.ResolvePath(typeof(TDomain).Name);

            IEnumerable<TDomain> domains = XmlController.LoadCollection<TDomain>();

            foreach (TDomain item in domains)
            {
                Assert.IsTrue(item.Validate());
            }
        }

        PathResolver pr = new PathResolver();
    }
}
